package base.tag;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.Tag;

public class BsCollapseTag extends BsContainerTag<Object> {

	private static final long serialVersionUID = 1L;
    
	private String rootId = "00";
	private String dataUrl = "";
	private String link = "center";
	
	@Override
	public int doEndTag() throws JspException {
		
		StringBuffer tag = new StringBuffer();
		String fheight = height;
		if(this.usedHeight.compareTo("") != 0)
		{
			fheight = "$(document).height() - " + this.usedHeight;
		}
		tag.append("<div class='col-xs-" + colWidth + "'>\n");
		tag.append("<div class='panel panel-info' id='divpanel" + name + "'>\n");
		tag.append("<div class='panel-heading'><h3 class='panel-title'>" + caption + "</h3></div>\n");
		tag.append("<div class='panel-group' id='" + name + "' role='tablist' aria-multiselectable='true' style='margin:10px;'>\n");
		tag.append("</div>\n");
		tag.append("</div>\n");
		tag.append("</div>\n");

		tag.append("<script type=\"text/javascript\">\n");
		if(fheight.compareTo("") != 0)
			tag.append("$('#" + name + "').css('height'," + fheight + ");\n");
		tag.append("bindCollapseData('" + name + "','" + dataUrl + "','" + rootId + "','" + link + "');\n");
		tag.append("</script>\n");
		
		output(tag);
		return Tag.EVAL_PAGE;
	}

	public String getRootId() {
		return rootId;
	}

	public void setRootId(String rootId) {
		this.rootId = rootId;
	}

	public String getDataUrl() {
		return dataUrl;
	}

	public void setDataUrl(String dataUrl) {
		this.dataUrl = dataUrl;
	}

	public String getLink() {
		return link;
	}

	public void setLink(String link) {
		this.link = link;
	}

	
}
